package com.ruoyi.ctcx.service.impl;

import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ctcx.domain.ro.InsuranceParam;
import com.ruoyi.ctcx.domain.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ctcx.mapper.TbInsuranceMainMapper;
import com.ruoyi.ctcx.domain.TbInsuranceMain;
import com.ruoyi.ctcx.service.ITbInsuranceMainService;

/**
 * 保险主Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-19
 */
@Service
public class TbInsuranceMainServiceImpl implements ITbInsuranceMainService 
{
    @Autowired
    private TbInsuranceMainMapper tbInsuranceMainMapper;

    /**
     * 查询保险主
     * 
     * @param id 保险主主键
     * @return 保险主
     */
    @Override
    public TbInsuranceMainVo selectTbInsuranceMainById(Long id)
    {
        return tbInsuranceMainMapper.selectTbInsuranceMainById(id);
    }

    /**
     * 查询保险主列表
     * 
     * @param insuranceParam 保险主
     * @return 保险主
     */
    @Override
    public List<TbInsuranceMainVo> selectTbInsuranceMainList(InsuranceParam insuranceParam)
    {
        return tbInsuranceMainMapper.selectTbInsuranceMainList(insuranceParam);
    }

    /**
     * 新增保险主
     * 
     * @param tbInsuranceMain 保险主
     * @return 结果
     */
    @Override
    public int insertTbInsuranceMain(TbInsuranceMain tbInsuranceMain)
    {
        tbInsuranceMain.setCreateTime(DateUtils.getNowDate());
        return tbInsuranceMainMapper.insertTbInsuranceMain(tbInsuranceMain);
    }

    /**
     * 修改保险主
     * 
     * @param tbInsuranceMain 保险主
     * @return 结果
     */
    @Override
    public int updateTbInsuranceMain(TbInsuranceMain tbInsuranceMain)
    {
        tbInsuranceMain.setUpdateTime(DateUtils.getNowDate());
        return tbInsuranceMainMapper.updateTbInsuranceMain(tbInsuranceMain);
    }

    /**
     * 批量删除保险主
     * 
     * @param ids 需要删除的保险主主键
     * @return 结果
     */
    @Override
    public int deleteTbInsuranceMainByIds(Long[] ids)
    {
        return tbInsuranceMainMapper.deleteTbInsuranceMainByIds(ids);
    }

    /**
     * 删除保险主信息
     * 
     * @param id 保险主主键
     * @return 结果
     */
    @Override
    public int deleteTbInsuranceMainById(Long id)
    {
        return tbInsuranceMainMapper.deleteTbInsuranceMainById(id);
    }

    @Override
    public List<TbInsuranceAllVo> getMainList(InsuranceParam insuranceParam) {
        return tbInsuranceMainMapper.getMainList(insuranceParam);
    }

    @Override
    public List<TbInsuranceXlMainVo> getXlMainList(InsuranceParam insuranceParam) {
        return tbInsuranceMainMapper.getXlMainList(insuranceParam);
    }

    /**
     * 获取保险项目累计保费支出
     * @param insuranceParam
     * @return
     */
    @Override
    public BigDecimal getTotalPremium(InsuranceParam insuranceParam) {
        return tbInsuranceMainMapper.getTotalPremium(insuranceParam);
    }

    /**
     * 首页
     * 获取费用
     * @param insuranceParam
     * @return
     */
    @Override
    public TbInsuranceTotalVo getTotalFee(InsuranceParam insuranceParam) {
        return tbInsuranceMainMapper.getTotalFee(insuranceParam);
    }

    /**
     * 首页
     * 投保人排名展示（按保费支出排名，展示前五名），包含投保人名称，保费支出，累计赔款收入
     * @param insuranceParam
     * @return
     */
    @Override
    public List<TbInsurancePaimingVo> getPaimingList(InsuranceParam insuranceParam) {
        return tbInsuranceMainMapper.getPaimingList(insuranceParam);
    }
}
